#ifndef UM_WIN32_AUTOCOMPLETE_EMAILADDRESS_H
#define UM_WIN32_AUTOCOMPLETE_EMAILADDRESS_H

class EmailAddress {

public:

	EmailAddress(const std::wstring & address) {
		finalConstruct(address);
	}

	EmailAddress(const std::wstring & address, const std::wstring & displayName, int encoding = 0) {
		finalConstruct(address);
		m_displayName = displayName;
	}

	std::wstring host() const {
		return m_host;
	}

	std::wstring user() const {
		return m_user;
	}

	std::wstring displayName() const {
		return m_displayName;
	}

	std::wstring address() const {
		return m_user + L"@" + m_host;
	}

	std::wstring toString() const {
		if (!m_displayName.empty()) {
			return m_displayName + L" <" + address() + L">";
		}
		else {
			return address();
		}
	}

private:

	void finalConstruct(const std::wstring & address) {
		size_t i = address.find('@');
		m_user = address.substr(0, i);
		m_host = address.substr(i + 1);
	}

	std::wstring m_displayName;
	std::wstring m_host;
	std::wstring m_user;
};

#endif // UM_WIN32_AUTOCOMPLETE_EMAILADDRESS_H